// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { BUNDLE_TYPE_ENUM } from "../base/EnumIndex";
import { LEVEL_TYPE, LevelManager } from "../manager/LevelManager";
import { UIManager } from "../manager/UIManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class PartnerItem extends cc.Component {

    @property(cc.Node)
    bg: cc.Node = null;

    @property({ type: [cc.SpriteFrame], displayName: "类型图片" })
    typeSprArr: Array<cc.SpriteFrame> = [];

    type: number;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    setBgSpr(type: number) {
        this.type = type;
        this.bg.getComponent(cc.Sprite).spriteFrame = this.typeSprArr[type - 1];
    }

    clickType() {
        UIManager.ins.closeAll();
        LevelManager.ins.selectLevelType = this.type;
        UIManager.ins.showUI("LevelUI", BUNDLE_TYPE_ENUM.HOME);
    }

    // update (dt) {}
}
